import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:jump_scape/js_data/js_member.dart';
import 'package:jump_scape/js_ui/js_activity/js_personal.dart';
import 'package:jump_scape/js_ui/js_activity/js_records.dart';
import 'package:jump_scape/js_ui/js_activity/js_topic.dart';
import 'package:jump_scape/js_ui/js_widget/js_image_view.dart';
import 'package:jump_scape/js_ui/js_widget/js_style.dart';

import '../../js_config.dart';
import '../../js_data/js_event.dart';

class JsHomeActivity extends StatefulWidget {
  static const url = 'home';
  const JsHomeActivity({super.key});

  @override
  State<StatefulWidget> createState() => _JsHomeActivity();
}

class _JsHomeActivity extends State<JsHomeActivity> {
  @override
  void initState() {
    super.initState();
    JsEventManager.statPage(page: JsEventName.jsNameHome);

    JsApp.initATT();
    JsApp.getVersionName();
    JsMember().synchronizationMember(onSuccess: (_) {}, onFailed: (_) {});
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () => Future.value(false),
      child: Scaffold(
        backgroundColor: Colors.white,
        body: Stack(
          children: [
            Align(
              alignment: Alignment.bottomCenter,
              child: jsImage('assets/gif/ic_home.gif', height: 232.r, fit: BoxFit.fitHeight, padding: EdgeInsets.only(bottom: 251.r)),
            ),
            jsImage('assets/image/ic_home_bg_top.png', width: double.infinity, fit: BoxFit.fitWidth),
            Align(
              alignment: Alignment.bottomCenter,
              child: jsImage('assets/image/ic_home_bg_bottom.png', width: double.infinity, fit: BoxFit.fitWidth),
            ),
            Positioned(
              top: ScreenUtil().statusBarHeight + 23.r,
              right: 16.r,
              child: Stack(
                children: [
                  jsImage('assets/image/ic_home_button_bg.png', height: 75.r, fit: BoxFit.fitHeight),
                  InkWell(
                    child: jsImage('assets/image/ic_home_records.png', width: 30.r, height: 30.r, padding: EdgeInsets.fromLTRB(22.r, 24.r, 7.r, 21.r)),
                    onTap: () {
                      Navigator.pushNamed(context, JsRecordsActivity.url);
                    },
                  ),
                  Positioned(
                    right: 0,
                    child: InkWell(
                      child: jsImage('assets/image/ic_home_personal.png', width: 30.r, height: 30.r, padding: EdgeInsets.fromLTRB(7.r, 24.r, 26.r, 21.r)),
                      onTap: () {
                        Navigator.pushNamed(context, JsPersonalActivity.url);
                      },
                    ),
                  ),
                ],
              ),
            ),
            Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                margin: EdgeInsets.only(bottom: 208.r),
                decoration: jsShapeRound(radius: 34.r, shadows: [
                  BoxShadow(offset: Offset(2.r, 4.r), color: Color(0xFFAE6060).withOpacity(0.12), blurRadius: 5.r),
                ]),
                child: InkWell(
                  child: Container(
                    clipBehavior: Clip.antiAlias,
                    decoration: jsShapeRound(radius: 34.r),
                    child: jsImage('assets/image/ic_home_start.png', height: 67.r, fit: BoxFit.fitHeight),
                  ),
                  onTap: () {
                    Navigator.pushNamed(context, JsTopicActivity.url);
                  },
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
